private void PrintByCmdExample1()
        {
            Bitmap bitmap = new Bitmap(Application.StartupPath + "\\123.png");
            LabelPrinterFactory factory = new LPFactory();
            Printer printer = factory.Create("Rongta RP4xx Series");//ӡΪ"Rongta RP4xx Series"

            byte[] header = Cmd.GetPrintCmdHeader(60, 60, 0, 0, 3, 8,false,false);//ֽſ 60 mm  ֽŸ߶ 60 mm ʼ 0 0 ӡٶ3 ӡŨ 8

            byte[] text1 = Cmd.GetTextPrintData(180, 80, "TSS24.BF2", 180, 2, 2, ""); 
            byte[] text2 = Cmd.GetTextPrintData(0, 70, "TSS24.BF2", 0, 1, 1, "ţ34234232322322");
            byte[] text3 = Cmd.GetTextPrintData(2, 100, "TSS24.BF2", 0, 1, 1, "룺34234232322322222");
            byte[] text4 = Cmd.GetTextPrintData(4, 130, "TSS24.BF2", 0, 1, 1, "ţ342342323");
            byte[] text5 = Cmd.GetTextPrintData(200, 130, "TSS24.BF2", 0, 1, 1, "أ111g");
            byte[] text6 = Cmd.GetTextPrintData(40, 180, "TSS24.BF2", 90, 1, 1, "");
            byte[] text7 = Cmd.GetTextPrintData(116, 180, "TSS24.BF2", 90, 1, 1, "");
            byte[] text8 = Cmd.GetTextPrintData(190, 180, "TSS24.BF2", 90, 1, 1, "Ԫ/5");
            byte[] text9 = Cmd.GetTextPrintData(260, 180, "TSS24.BF2", 90, 1, 1, "g");

            byte[] text10 = Cmd.GetTextPrintData(60, 180, "1", 90, 1, 1, "2017.01.09");
            byte[] text11 = Cmd.GetTextPrintData(130, 180, "1", 90, 1, 1, "2017.01.09");
            byte[] text12 = Cmd.GetTextPrintData(210, 180, "1", 90, 1, 1, "2000.22");
            byte[] text13 = Cmd.GetTextPrintData(274, 180, "1", 90, 1, 1, "10000.22g");

            byte[] barX = Cmd.GetBarPrintData(8, 165, 300, 2); //൱ڴӡһˮƽ
            byte[] barY1 = Cmd.GetBarPrintData(83, 165, 2, 120); //൱ڴӡһֱ
            byte[] barY2 = Cmd.GetBarPrintData(154, 165, 2, 120); //൱ڴӡһֱ
            byte[] barY3 = Cmd.GetBarPrintData(225, 165, 2, 120); //൱ڴӡһֱ

            byte[] qrCodeData = Cmd.GetQRCodePrintData(284, 190, 'M', 4, 0, "adbaikkk123"); //ԲοƣͬʱοTSCֲָἴ
            byte[] barCodeData = Cmd.GetBARCodePrintData(2, 310, "128M", 80, false, 0, 2, 5, "24sdafsdf35634");

            byte[] printCopyData = Cmd.GetPrintCopyCmd(1);//ӡ 1

            printer.Open();//򿪴ӡ

            int writeLen = header.Length;
            printer.Write(header, ref writeLen);//ͷ(WriteӡָȻҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ)

            writeLen = text1.Length;
            printer.Write(text1, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text2.Length;
            printer.Write(text2, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text3.Length;
            printer.Write(text3, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text4.Length;
            printer.Write(text4, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text5.Length;
            printer.Write(text5, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text6.Length;
            printer.Write(text6, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text7.Length;
            printer.Write(text7, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text8.Length;
            printer.Write(text8, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text9.Length;
            printer.Write(text9, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text10.Length;
            printer.Write(text10, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text11.Length;
            printer.Write(text11, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text12.Length;
            printer.Write(text12, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text13.Length;
            printer.Write(text13, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = barX.Length;
            printer.Write(barX, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = barY1.Length;
            printer.Write(barY1, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = barY2.Length;
            printer.Write(barY2, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = barY3.Length;
            printer.Write(barY3, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = barCodeData.Length;
            printer.Write(barCodeData, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = qrCodeData.Length;
            printer.Write(qrCodeData, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = printCopyData.Length;
            printer.Write(printCopyData, ref writeLen);
            printer.Close();
        }

        private void PrintByCmdExample2()
        {
            LabelPrinterFactory factory = new LPFactory();
            Printer printer = factory.Create("Rongta RP4xx Series");//ӡΪ"Rongta RP4xx Series"
            byte[] header = Cmd.GetPrintCmdHeader(60, 60, 0, 0, 3, 8,true,true);//ֽſ 60 mm  ֽŸ߶ 60 mm ʼ 0 0 ӡٶ3 ӡŨ 8

            Bitmap bitmap1 = new Bitmap(Application.StartupPath + "\\123.png");
            byte[] bitmapData1 = Cmd.GetBitmapPrintData(4, 20, bitmap1);//ӡλͼ

            Bitmap bitmap2 = new Bitmap(Application.StartupPath + "\\test.bmp");
            byte[] bitmapData2 = Cmd.GetBitmapPrintData(4, 220, bitmap2);//ӡλͼ     

            byte[] text1 = Cmd.GetTextPrintData(200, 8, "TSS24.BF2", 0, 1, 1, "Դӡ1");
            byte[] text2 = Cmd.GetTextPrintData(200, 32, "TSS24.BF2", 0, 1, 2, "Դӡ2");
            byte[] text3 = Cmd.GetTextPrintData(200, 96, "TSS24.BF2", 0, 2, 2, "Դӡ3");
            byte[] text4 = Cmd.GetTextPrintData(200, 160, "2", 0, 4, 4, "test4");

            byte[] printCopyData = Cmd.GetPrintCopyCmd(1);//ӡ

            printer.Open();//򿪴ӡ

            int writeLen = header.Length;
            printer.Write(header, ref writeLen);//ͷ(WriteӡָȻҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ)

            writeLen = bitmapData1.Length;
            printer.Write(bitmapData1, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = bitmapData2.Length;
            printer.Write(bitmapData2, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text1.Length;
            printer.Write(text1, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text2.Length;
            printer.Write(text2, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text3.Length;
            printer.Write(text3, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = text4.Length;
            printer.Write(text4, ref writeLen); //ҲԷԼ֯ıǩӡмÿĽβҪ \r\n 2ַ

            writeLen = printCopyData.Length;
            printer.Write(printCopyData, ref writeLen);
            printer.Close();
        }